package com.sf.sms.examination.action;

import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.sf.sms.examination.service.SoftwareFlowService;
import com.sf.sms.software.entity.Software;
import com.sf.sms.utils.ParseUtil;

@Controller
@RequestMapping("/SoftwareFlow")
public class SoftwareFlowAction {
	
	
	@Autowired
	SoftwareFlowService flowService;

	
    @ResponseBody
    @RequestMapping(value = "/flowPass" , method = RequestMethod.GET)
	public Map<String, Object> flowApprove(HttpSession session,@RequestParam("software")String software){
    	
    	String path=session.getServletContext().getRealPath("");
    	Software softwareEN =ParseUtil.fromJson(software, Software.class);
    	Map<String, Object> resultMap  =flowService.flowPass(softwareEN,path);
    
		return resultMap;
		
	}
    
    @ResponseBody
    @RequestMapping(value = "/flowRefuse", method = RequestMethod.GET)
	public Map<String, Object> flowRepulse(@RequestParam("softId")String softId){
    	Map<String, Object> resultMap = flowService.flowRefuse(softId);
		return resultMap;
	}
    
    @ResponseBody
    @RequestMapping(value = "/getSoftwareById", method = RequestMethod.GET)
	public Map<String, Object> getSoftwareById(@RequestParam("softId")String softId){
    	
    	Map<String, Object> resultMap = flowService.getSoftwareById(softId);
		return resultMap;
	}
    
}
